<template>
  <el-drawer
    :title="title"
    v-if="visible"
    :visible.sync="visible"
    direction="rtl"
    size="50%"
    :before-close="handleClose">
    <el-row>
      <el-col :span="24" style="text-align: center;">
        <el-button icon="el-icon-plus" style="width: 95%;border: #409EFF dotted 1px;" @click="doAdd">新增</el-button>
      </el-col>
      <el-col :span="24">
        <qd-view in-side v-if="type==='qd'" ref="data-view" :user-id="userId"/>
        <jcjh-view in-side v-if="type==='jcjh'" ref="data-view" :user-id="userId"/>
        <jf-view in-side v-if="type==='jf'" ref="data-view" :user-id="userId"/>
        <th-view in-side v-if="type==='th'" ref="data-view" :user-id="userId"/>
        <leave-view in-side v-if="type==='leave'" ref="data-view" :user-id="userId"/>
        <gkcs-view in-side v-if="type==='gkcs'" ref="data-view" :user-id="userId"/>
        <wfxy-view in-side v-if="type==='wfxy'" ref="data-view" :user-id="userId"/>
        <dzbg-view in-side v-if="type==='dzbg'" ref="data-view" :user-id="userId"/>
        <yzwfxy-view in-side v-if="type==='yzwfxy'" ref="data-view" :user-id="userId"/>
        <ywwczl-view in-side v-if="type==='ywwczl'" ref="data-view" :user-id="userId"/>
        <wgbg-view in-side v-if="type==='wgbg'" ref="data-view" :user-id="userId"/>
        <ndkc-view in-side v-if="type==='ndkc'" ref="data-view" :user-id="userId"/>
        <bfjh-view in-side v-if="type==='bfjh'" ref="data-view" :user-id="userId"/>
        <bfqk-view in-side v-if="type==='bfqk'" ref="data-view" :user-id="userId"/>
        <bfcx-view in-side v-if="type==='bfcx'" ref="data-view" :user-id="userId"/>
        <rylxzh-view in-side v-if="type==='rylxzh'" ref="data-view" :user-id="userId"/>
      </el-col>
    </el-row>
  </el-drawer>
</template>

<script>
import QdView from '@/views/event/qd'
import JcjhView from '@/views/event/jcjh'
import JfView from '@/views/event/jf'
import ThView from '@/views/event/th'
import LeaveView from '@/views/event/leave'
import GkcsView from '@/views/event/gkcs'
import WfxyView from '@/views/event/wfxy'
import DzbgView from '@/views/event/dzbg'
import YzwfxyView from "@/views/event/yzwfxy";
import YwwczlView from "@/views/event/ywwczl";
import WgbgView from "@/views/event/wgbg";
import NdkcView from '@/views/event/ndkc'
import BfjhView from '@/views/event/bfPlan'
import BfqkView from '@/views/event/bfRecord'
import BfcxView from '@/views/event/bfResult'
import RylxzhView from '@/views/event/changeType'

const EVENT_DICT = {
  qd: {title: '签到信息'},
  jcjh: {title: '检测计划'},
  jf: {title: '家访'},
  th: {title: '谈话'},
  leave: {title: '请假'},
  gkcs: {title: '管控措施'},
  wfxy: {title: '违反协议'},
  dzbg: {title: '地址变更'},
  yzwfxy: {title: '严重违反协议'},
  ywwczl: {title: '药物维持治疗'},
  wgbg: {title: '违规报告'},
  ndkc: {title: '年度考察'},
  bfjh: {title: '帮扶计划'},
  bfqk: {title: '帮扶情况'},
  bfcx: {title: '帮扶成效'},
  rylxzh: {title: '人员类型转换'},
}

export default {
  name: "UserEventSideDrawer",
  components: {
    QdView, JcjhView, JfView, ThView, LeaveView, GkcsView, WfxyView, DzbgView,
    YzwfxyView, YwwczlView, WgbgView, NdkcView, BfjhView, BfqkView, BfcxView, RylxzhView
  },
  props: {
    userId: String
  },
  data() {
    return {
      type: undefined,
      title: '',
      visible: false,
      loading: false,
      tableData: []
    }
  },
  methods: {
    doAdd() {
      if (this.$refs["data-view"].handleAdd) {
        this.$refs["data-view"].handleAdd();
      }
    },
    open(type, openAdd=false) {
      this.visible = true;
      this.type = type
      this.title = EVENT_DICT[type].title;
      if (openAdd) {
        this.$nextTick(()=> {
          this.$refs["data-view"].handleAdd();
        })
      }
    },
    handleClose() {
      this.visible = false;
      this.$emit('refresh', this.type)
    },
  }
}
</script>

<style scoped>

</style>
